<?php
/**
 * dao taskdao
 * @package app-drama_lib_dao
 */
load_lib('/dao/basedao');
/**
 * dao taskdao
 * @author pandajingjing
 * @package app-drama_lib_dao
 */
class dao_taskdao extends dao_basedao{

    /**
	 * 新增操作队列信息
	 * @param array $p_arrParam
	 * @return int/false
	 */
    static function addShowQueue($p_arrParam){
        $p_arrParam['CREATETIME']=parent::getTime();
        return parent::addData('drama_queue',$p_arrParam,'drama_db');
    }

    /**
	 * 消费Drama的队列消息
	 * @param mix $p_mixUserFunc
	 * @param string $p_strQueue
	 * @param string $p_strChannel
	 */
    static function consumeMessage($p_mixUserFunc,$p_strQueue='queue_drama',$p_strChannel='mq_default_master'){
        parent::consumeMessage($p_mixUserFunc,'queue_drama');
    }

    /**
	 * 更新Drama队列
	 * @param array $p_arrParam
	 * @return int
	 */
    static function updQueue($p_arrParam){ //队列状态,1-等待,2-正在执行,3-执行结束,4-执行失败,5-跳过执行
        switch($p_arrParam['DSTATUS']){
            case 2:
                $p_arrParam['STARTTIME']=parent::getRealTime();
                break;
            case 3:
            case 4:
            case 5:
                $p_arrParam['FINISHTIME']=parent::getRealTime();
                break;
        }
        return parent::updData('drama_queue',$p_arrParam,'drama_db');
    }

    /**
	 * 添加导入文件
	 * @param array $p_arrParam
	 * @return int/false
	 */
    static function addImportFile($p_arrParam){
        $p_arrParam['CREATETIME']=parent::getRealTime();
        return parent::addData('drama_import',$p_arrParam,'drama_db');
    }

    /**
	 * 获取队列列表
	 * @param $p_arrParam
	 * @return array
	 */
    static function getQueueList($p_arrParam){
        $strSQL='';
        $arrParam=array();
        $objORM=parent::getORM('drama_queue','drama_db');
        if(isset($p_arrParam['SORT'])){
            $objORM->setOrder($p_arrParam['SORT']);
        }
        return $objORM->getList($strSQL,$arrParam);
    }

    /**
	 * 获取导入文件
	 * @param string $p_strKey
	 * @return array/null
	 */
    static function getImportFile($p_strKey){
        $objORM=parent::getORM('drama_import','drama_db');
        $objORM->FILEKEY=$p_strKey;
        return $objORM->getRow();
    }
}